package errmsg

const (
	SUCCESS = 200
	ERROR   = 500

	// token
	TOKEN_CREATE_FAILED  = 901
	TOKEN_PARSE_FAILED   = 902
	TOKEN_NOEXIST_FAILED = 904
	TOKEN_TYPE_FAILED    = 905

	// 1000~1999 公告错误
	BILLBOARD_SELECT_ALL_FAILED = 1000

	// 2000~2999 每日一句错误
	TIP_SELECT_FAILED = 2000

	// 3000~3999 推广连接错误
	PROMOTION_SELECT_FAILED = 3000

	// 4000~4999 用户错误
	USER_REGISTER_USERNAME_FAILED = 4000
	USER_REGISTER_EMAIL_FAILED    = 4001
	USER_REGISTER_FAILED          = 4002
	USER_NAME_OR_PASS_FAILED      = 4003
	USER_SELECT_FAILED            = 4004
	USER_UPDATE_FAILED            = 4005

	// 5000~5999 文章错误
	POST_SELECT_FAILED = 5000
	POST_CREATE_FAILED = 5001
	POST_DELETE_FAILED = 5002

	// 6000~6999 标签错误
	TAG_SELECT_FAILED = 6000
	TAG_INSERT_FAILED = 6001
	TAG_DELETE_FAILED = 6002

	// 7000~7999 关系错误
	RELATION_SELELCT_FAILED = 7000
	RELATION_CREATE_FAILED  = 7001
	RELATION_DELETE_FAILED  = 7002

	// 8000~8999 评论错误
	COMMENT_SELECT_FAILED = 8000
	COMMENT_INSERT_FAILED = 8001
)

var codeMsg = map[int]string{
	SUCCESS: "OK",
	ERROR:   "FAILED",

	TOKEN_CREATE_FAILED:  "token生成失败",
	TOKEN_PARSE_FAILED:   "token解析失败",
	TOKEN_NOEXIST_FAILED: "token不存在",
	TOKEN_TYPE_FAILED:    "token类型错误",

	BILLBOARD_SELECT_ALL_FAILED: "查询所有公告失败",

	TIP_SELECT_FAILED: "查询每日一句失败",

	PROMOTION_SELECT_FAILED: "查询推广链接失败",

	USER_REGISTER_USERNAME_FAILED: "用户名已存在",
	USER_REGISTER_EMAIL_FAILED:    "邮箱已存在",
	USER_REGISTER_FAILED:          "注册失败",
	USER_NAME_OR_PASS_FAILED:      "用户名或密码错误",
	USER_SELECT_FAILED:            "查询用户失败",
	USER_UPDATE_FAILED:            "更新用户失败",

	POST_SELECT_FAILED: "帖子查询失败",
	POST_CREATE_FAILED: "帖子创建失败",
	POST_DELETE_FAILED: "帖子删除失败",

	TAG_SELECT_FAILED: "标签查询失败",
	TAG_INSERT_FAILED: "添加标签失败",
	TAG_DELETE_FAILED: "删除标签失败",

	RELATION_SELELCT_FAILED: "关系不存在",
	RELATION_CREATE_FAILED:  "关系增加失败",
	RELATION_DELETE_FAILED:  "关系删除失败",

	COMMENT_SELECT_FAILED: "评论查询失败",
	COMMENT_INSERT_FAILED: "评论增加失败",
}

func GetErrMsg(code int) string {
	return codeMsg[code]
}
